package com.wuzf.navigation_test.utils;

import android.annotation.SuppressLint;
import android.app.Application;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class MyApplication {

    public static Application getApplication() {
        Application result = null;
        try {
            @SuppressLint("PrivateApi") Method method = Class.forName("android.app.ActivityThread").getMethod("currentApplication");
            result = (Application) method.invoke(null);
        } catch (NoSuchMethodException | ClassNotFoundException | IllegalAccessException | InvocationTargetException e) {
            e.printStackTrace();
        }
        return result;
    }
}
